package com.mofofa.maozy.info.cotediva

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations
import com.mofofa.maozy.base.BaseViewModel
import com.mofofa.maozy.data.*
import com.mofofa.maozy.network.ApiUserReposity

/** 科特钱包viewModel */
class WalletInfoFcfaViewModel : BaseViewModel() {

    /** 钱包列表 */
    val mMaozyWalletMaozyListMaozyFCFA = mutableListOf<RevObjWalletListFcfa>()

    /** 获取钱包列表 */
    private val mMaozyGetMaozyWalletMaozyListMaozyFCFAMaozyLiveData =
        MutableLiveData<ReqBase>()

    /** 保存钱包 */
    private val mMaozySaveMaozyWalletMaozyFCFAMaozyLiveData =
        MutableLiveData<ReqSaveWalletFcFa>()

    /** 删除钱包 */
    private val mMaozyDeleteMaozyWalletMaozyFCFAMaozyLiveData =
        MutableLiveData<ReqDeleteWalletFcfa>()

    /** 保存钱包认证状态 */
    private val mMaozySaveMaozyBvnMaozyFCFAMaozyLiveData =
        MutableLiveData<ReqBase>()

    /** 获取钱包列表 */
    val onMaozyFetchMaozyWalletMaozyListMaozyFCFAMaozyLiveData =
        Transformations.switchMap(
            mMaozyGetMaozyWalletMaozyListMaozyFCFAMaozyLiveData
        ) { query ->
            ApiUserReposity.getMaozyWalletMaozyListMaozyFCFA(this, query)
        }

    /** 保存钱包 */
    val onMaozySaveMaozyWalletMaozyFCFAMaozyLiveData =
        Transformations.switchMap(mMaozySaveMaozyWalletMaozyFCFAMaozyLiveData) { query ->
            ApiUserReposity.saveMaozyWalletMaozyFCFA(this, query)
        }

    /** 删除钱包 */
    val onMaozyDeleteMaozyWalletMaozyFCFAMaozyLiveData =
        Transformations.switchMap(mMaozyDeleteMaozyWalletMaozyFCFAMaozyLiveData) { query ->
            ApiUserReposity.deleteMaozyWalletMaozyFCFA(this, query)
        }

    /** 保存钱包认证状态 */
    val onMaozySaveMaozyBvnMaozyFCFAMaozyLiveData =
        Transformations.switchMap(mMaozySaveMaozyBvnMaozyFCFAMaozyLiveData) { query ->
            ApiUserReposity.saveMaozyBvnMaozyFCFA(this, query)
        }

    /** 获取钱包列表 */
    fun getMaozyWalletMaozyListMaozyFCFA(reqBase: ReqBase = ReqBase()) {
        mMaozyGetMaozyWalletMaozyListMaozyFCFAMaozyLiveData.value = reqBase
    }

    /** 保存钱包 */
    fun saveMaozyWalletMaozyFCFA(reqSaveWalletFcFa: ReqSaveWalletFcFa) {
        mMaozySaveMaozyWalletMaozyFCFAMaozyLiveData.value = reqSaveWalletFcFa
    }

    /** 删除钱包 */
    fun deleteMaozyWalletMaozyFCFA(reqDeleteWalletFcfa: ReqDeleteWalletFcfa) {
        mMaozyDeleteMaozyWalletMaozyFCFAMaozyLiveData.value = reqDeleteWalletFcfa
    }

    /** 保存钱包认证状态 */
    fun saveMaozyBvnMaozyFCFA(reqBase: ReqBase) {
        mMaozySaveMaozyBvnMaozyFCFAMaozyLiveData.value = reqBase
    }

    /** 初始化钱包列表 */
    fun initMaozyWalletMaozyListMaozyFCFA(list: List<RevObjWalletListFcfa>) {
        mMaozyWalletMaozyListMaozyFCFA.clear()
        mMaozyWalletMaozyListMaozyFCFA.addAll(list)
    }
}